<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var c = console.log.bind(document)
        var s = 'MCMXCIV'
        var romanToInt = function(s) {
        var I = 1
        
        
        
        
        
        
        
        for(var i=s.length;i>0;i--) {
            var str = []
            c(str)
            var V = 5
            var X = 10
            var L = 50
            var C = 100
            var D = 500
            var M = 1000
            var a = 0
            if(str[i] == 'V') {
                str[i] = 1000
                c(str[i])
            }
            c(str[i])
            if(str[i] >= str[i+1]){
                a += str[i]+str[i+1]
            }else {
                a-=str[i]-str[i+1]
            }
        }
        console.log(a)
        return a
        };
        romanToInt(s)
    </script>
</body>
</html>